home *** CD-ROM | disk | FTP | other *** search
- { Show & Change Palette/256 Colors }
-
- uses SVGA256,Txt;
-
- var File1:file;
- Pal:array[0..767] of byte;
-
- { ─────────────── Palette ─────────────── }
- procedure Palette;
- const
- Color:array[0..2] of string[5]=('Red','Green','Blue');
- Help:array[0..6] of string[12]=(
- 'RGB','Shade +1','Shade +10','Shade auto','Change color',
- 'Copy color','Save & quit');
- Keys:array[0..6] of string[10]=(
- 'Up,down','Left,right','Shift L,R','- +','Tab','*','Esc');
- C:array[1..3] of byte=(104,9,15); { Text,Title,Select }
- var K,I,J,P,No:integer;
- St:string[3];
- Font1:array[0..3071] of byte;
- { ─────────────── SelectColor ─────────────── }
- procedure SelectColor;
- var I:integer;
- begin
- repeat
- Box(31+20*(No and 15),69+20*(No shr 4),21,21,C[3]);
- K:=Key;
- Box(31+20*(No and 15),69+20*(No shr 4),21,21,C[1]);
- case K of
- $4800:Dec(No,16); $5000:Inc(No,16); { Up, Down }
- $4B00:Dec(No); $4D00:Inc(No); { Left, Right }
- end;
- if No<0 then Inc(No,256); if No>255 then Dec(No,256);
- Bar(480,80,80,16,C[1]);
- Str(No:3,St); Print(480,80,C[3],St);
- for I:=0 to 2 do begin
- Bar(480,100+20*I,80,16,C[1]);
- Str(Pal[3*No+I]:3,St); Print(480,100+20*I,C[3],St);
- end;
- Bar(381,166,108,72,No);
- until (K=$1C0D) or (K=$011B) or (K=$0F09); { Enter,Esc,Tab }
- end; { End SelectColor }
- { ─────────────── CopyColor ─────────────── }
- procedure CopyColor;
- var T:integer;
- begin
- T:=No;
- repeat
- Box(31+20*(No and 15),69+20*(No shr 4),21,21,C[3]);
- K:=Key;
- Box(31+20*(No and 15),69+20*(No shr 4),21,21,C[1]);
- case K of
- $4800:Dec(No,16); $5000:Inc(No,16); { Up,Down }
- $4B00:Dec(No); $4D00:Inc(No); { Left,Right }
- end;
- if No<0 then Inc(No,256);
- if No>255 then Dec(No,256);
- until (K=$1C0D) or (K=$011B);
- Move(Pal[3*T],Pal[3*No],3); SetPalette(No,1,Pal[3*T]);
- Bar(32+20*(No and 15),70+20*(No shr 4),20,20,T);
- No:=T;
- end; { End CopyColor }
- begin
- SetPalette(0,256,Pal);
- FileRead('1616sim#.fnt',0,96,32,Font1);
- InstallFont(2,16,16,32,96,16,Font1);
- Bar(0,0,640,20,C[2]); Bar(0,20,640,440,C[1]); Bar(0,460,640,20,C[2]);
- Print2(20, 2,64,'Palette V1.1/VESA 640x480, 256 Colors');
- Print2(20,462,64,'Copyright (C) 1994 by Jou-Nan Chen');
- for J:=0 to 15 do for I:=0 to 15 do Bar(20*I+32,20*J+70,19,19,16*J+I);
- K:=0; No:=32; P:=0; J:=0; { J>=0 --> Inc/dec color value }
- Print(380,80,C[3],'Color'); Print(480,80,C[3],' 32');
- for I:=0 to 2 do begin
- Print(380,100+20*I,C[3],Color[I]);
- Str(Pal[3*No+I]:3,St); Print(480,100+20*I,C[3],St);
- end;
- Box(380,165,110,74,C[3]); Bar(381,166,108,72,No);
- for I:=0 to 6 do begin
- Print(380,250+20*I,C[3],Keys[I]);
- Print(480,250+20*I,C[3],Help[I]);
- end;
- Bar(370,100+20*P,80,16,C[2]); Print(380,100+20*P,C[3],Color[0]);
- repeat { Main loop }
- case J of
- 1:begin I:=3*No+P; if Pal[I]>0 then Dec(Pal[I]) else J:=0; end;
- 2:begin I:=3*No+P; if Pal[I]<63 then Inc(Pal[I]) else J:=0; end;
- end;
- if J>0 then begin
- SetPalette(No,1,Pal[3*No]);
- Bar(480,100+20*P,80,16,C[1]);
- Str(Pal[I]:3,St); Print(480,100+20*P,C[3],St);
- Delay(30);
- end;
- if KeyPressed=1 then begin
- K:=Key; J:=0;
- Bar(370,100+20*P,80,16,C[1]); Print(380,100+20*P,C[3],Color[P]);
- case K of
- $4800:begin Dec(P); if P<0 then P:=2; end; { Up }
- $5000:begin Inc(P); if P>2 then P:=0; end; { Down }
- $4B00:begin I:=3*No+P; if Pal[I]>0 then Dec(Pal[I]); end; { Left }
- $4D00:begin I:=3*No+P; if Pal[I]<63 then Inc(Pal[I]); end; { Right }
- $4B34:begin I:=3*No+P; if Pal[I]>9 then Dec(Pal[I],10); end; { s-L }
- $4D36:begin I:=3*No+P; if Pal[I]<54 then Inc(Pal[I],10); end; { s-R }
- $372A:CopyColor; { * }
- $4A2D:J:=1;
- $4E2B:J:=2;
- $0F09:SelectColor;
- end; { Left,Rigft,-,+ }
- if (K=$4B00) or (K=$4D00) or (K=$4B34) or (K=$4D36) then begin
- SetPalette(No,1,Pal[3*No]);
- Bar(480,100+20*P,80,16,C[1]);
- Str(Pal[I]:3,St); Print(480,100+20*P,C[3],St);
- end;
- Bar(370,100+20*P,80,16,C[2]); Print(380,100+20*P,C[3],Color[P]);
- end;
- until K=($011B); { Esc }
- end;
-
- var I:integer;
- Pal0:array[0..767] of byte;
- begin
- if ParamCount=0 then
- begin Writeln('Usage: Palette Filename'); Halt(1); end;
- if FileLen(ParamStr(1),1)<=0 then
- begin Writeln('Error: File "',ParamStr(1),'" not found !'); Halt(1); end;
- if TestVESA=0 then
- begin Writeln('VESA driver not installed !'); Halt(1); end;
- FileRead(ParamStr(1),0,256,3,Pal);
- SetMode(3); Move(Pal,Pal0,768);
- Palette;
- for I:=0 to 767 do if Pal[I]<>Pal0[I] then begin
- FileWrite(ParamStr(1),0,256,3,Pal);
- I:=767;
- end;
- SetMode(0);
- end.
-